package com.jobsys.filter;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * servlet 过滤器
 * 
 * @author pc-12
 *
 */
public class AnnotationHandleFilter implements Filter {

	@Override
	public void init(FilterConfig filterConfig) throws ServletException {
		// TODO Auto-generated method stub

	}

	@Override
	public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
			throws IOException, ServletException {
		// TODO Auto-generated method stub
		HttpServletRequest httpRequest = (HttpServletRequest) request;
		HttpServletResponse httpResponse = (HttpServletResponse) response;
		httpRequest.setCharacterEncoding("UTF-8");
		String requestPath = httpRequest.getRequestURI();
		String requestServer = requestPath.substring(0, requestPath.indexOf("/", 1));
		String filterPath = httpRequest.getServletPath();
		String queryString = httpRequest.getQueryString();
		String action = "";
		if (queryString != null && !queryString.equals("")) {
			if (queryString.indexOf("&") != -1) {
				action = "?" + queryString.substring(0, queryString.indexOf("&"));
			} else {
				action = "?" + queryString;
			}
		}

		chain.doFilter(request, response); // 继续执行
	}

	@Override
	public void destroy() {
		// TODO Auto-generated method stub

	}

}
